package com.hongxun.project.assets.iJointPole.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hongxun.framework.aspectj.lang.annotation.Log;
import com.hongxun.framework.aspectj.lang.enums.BusinessType;
import com.hongxun.project.assets.iJointPole.domain.IJointPole;
import com.hongxun.project.assets.iJointPole.service.IIJointPoleService;
import com.hongxun.framework.web.controller.BaseController;
import com.hongxun.framework.web.page.TableDataInfo;
import com.hongxun.framework.web.domain.AjaxResult;
import com.hongxun.common.utils.poi.ExcelUtil;

/**
 * 同杆架设 信息操作处理
 * 
 * @author hongxun
 * @date 2019-03-19
 */
@Controller
@RequestMapping("/assets/iJointPole")
public class IJointPoleController extends BaseController
{
    private String prefix = "assets/iJointPole";
	
	@Autowired
	private IIJointPoleService iJointPoleService;
	
	@RequiresPermissions("assets:iJointPole:view")
	@GetMapping()
	public String iJointPole()
	{
	    return prefix + "/iJointPole";
	}
	
	/**
	 * 查询同杆架设列表
	 */
	@RequiresPermissions("assets:iJointPole:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(IJointPole iJointPole)
	{
		startPage();
        List<IJointPole> list = iJointPoleService.selectIJointPoleList(iJointPole);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出同杆架设列表
	 */
	@RequiresPermissions("assets:iJointPole:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(IJointPole iJointPole)
    {
    	List<IJointPole> list = iJointPoleService.selectIJointPoleList(iJointPole);
        ExcelUtil<IJointPole> util = new ExcelUtil<IJointPole>(IJointPole.class);
        return util.exportExcel(list, "iJointPole");
    }
	
	/**
	 * 新增同杆架设
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存同杆架设
	 */
	@RequiresPermissions("assets:iJointPole:add")
	@Log(title = "同杆架设", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(IJointPole iJointPole)
	{		
		return toAjax(iJointPoleService.insertIJointPole(iJointPole));
	}

	/**
	 * 修改同杆架设
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") String id, ModelMap mmap)
	{
		IJointPole iJointPole = iJointPoleService.selectIJointPoleById(id);
		mmap.put("iJointPole", iJointPole);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存同杆架设
	 */
	@RequiresPermissions("assets:iJointPole:edit")
	@Log(title = "同杆架设", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(IJointPole iJointPole)
	{		
		return toAjax(iJointPoleService.updateIJointPole(iJointPole));
	}
	
	/**
	 * 删除同杆架设
	 */
	@RequiresPermissions("assets:iJointPole:remove")
	@Log(title = "同杆架设", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(iJointPoleService.deleteIJointPoleByIds(ids));
	}
	
}
